<?php

class KakisController extends \BaseController {

	/**
	 * Display a listing of kakis
	 *
	 * @return Response
	 */
	public function index()
	{
		$kakis = Kaki::all();

		return View::make('kakis.index', compact('kakis'));
	}

	/**
	 * Show the form for creating a new kaki
	 *
	 * @return Response
	 */
	public function create()
	{
		return View::make('kakis.create');
	}

	/**
	 * Store a newly created kaki in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		$validator = Validator::make($data = Input::all(), Kaki::$rules);

		if ($validator->fails())
		{
			return Redirect::back()->withErrors($validator)->withInput();
		}

		Kaki::create($data);

		return Redirect::route('kakis.index');
	}

	/**
	 * Display the specified kaki.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		$kaki = Kaki::findOrFail($id);

		return View::make('kakis.show', compact('kaki'));
	}

	/**
	 * Show the form for editing the specified kaki.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		$kaki = Kaki::find($id);

		return View::make('kakis.edit', compact('kaki'));
	}

	/**
	 * Update the specified kaki in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		$kaki = Kaki::findOrFail($id);

		$validator = Validator::make($data = Input::all(), Kaki::$rules);

		if ($validator->fails())
		{
			return Redirect::back()->withErrors($validator)->withInput();
		}

		$kaki->update($data);

		return Redirect::route('kakis.index');
	}

	/**
	 * Remove the specified kaki from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		Kaki::destroy($id);

		return Redirect::route('kakis.index');
	}

}
